home *** CD-ROM | disk | FTP | other *** search
- on pcalculatecoords
- -- Read and calculate the Coordinates for the Polhemus Patriot wand
- global vX
- global vY
- global vZ
- global pclick
-
- global testvX
- global testvY
- global testvZ
-
- --pclick = 0
-
-
- --override the polhemus if the cursor is in the tactile model display
-
- if the mouseH > 0 then
- vX = float((float(the mouseH) - 1024.0) / 32.0)
- vY = float(float(the mouseV) / 32.0)
-
- --pclick = 0
-
- else
- myfile_x = new xtra("fileio")
- openFile(myfile_x, "polhemus/z.txt", 0)
- vXtemp = readFile(myfile_x)
-
- --this checks for misread files
- if vXtemp > -500 then
- vX = vXtemp
- end if
-
-
- --this tests the data and makes sure it is within range
- if vX > 32.0 then
- vX = 32.0
- end if
- if vX < 0.0 then
- vX = 0.0
- end if
-
-
- myfile_y = new xtra("fileio")
- openFile(myfile_y, "polhemus/y.txt", 0)
- vYtemp = readFile(myfile_y)
-
- --this checks for misread files
- if vYtemp > -500 then
- vY = vYtemp
- end if
-
-
- --this tests the data to make sure it is within range
- if vY < 0.0 then
- vY = 0.0
- end if
- if vY > 24.0 then
- vY = 24.0
- end if
-
- --myfile_z = new xtra("fileio")
- --openFile(myfile_z, "polhemus/x.txt", 0)
- --vZ = readFile(myfile_z)
- --vZ = 0.0
- --put vX
- --put vY
-
- myfile_pclick = new xtra("fileio")
- openFile(myfile_pclick, "polhemus/click.txt", 0)
- pclick = readFile(myfile_pclick)
-
- put pclick into field "clickdisplay"
-
- end if
-
- the floatPrecision = 2
-
- vX = float(vX)
- vY = float(vY)
- vZ = float(vZ)
-
- --change the polhemus data from model units to pixels
- --our total screen size is 1024 x 768
- --out current model size is 32" x 24"
-
- global vX_adjusted
- global vY_adjusted
- global vZ_adjusted
-
- global modelscale_x
- global modelscale_y
-
- global screenscale_x
- global screenscale_y
-
- modelscale_x = 32.0
- modelscale_y = 24.0
-
- --this is used to adjust the calibration of the wand...how well the position matches the grid
- global calibrationadjust_x
- global calibrationadjust_y
- calibrationadjust_x = the text of field "calibrationadjust_x"
- calibrationadjust_y = the text of field "calibrationadjust_y"
-
- --zero out the calibration if the mouse is being used
- if the mouseH > 0 then
- calibrationadjust_x = 0.0
- calibrationadjust_y = 0.0
- end if
-
-
- screenscale_x = 1024.0
- screenscale_y = 768.0
-
- the floatPrecision = 2
-
- adjustment_x = float(screenscale_x / (modelscale_x+calibrationadjust_x))
- adjustment_y = float(screenscale_y / (modelscale_y+calibrationadjust_y))
-
- vX_adjusted = vX * adjustment_x
- vY_adjusted = vY * adjustment_y
-
- if vX_adjusted > 1023.0 then
- --vX_adjusted = 1023.0
- end if
-
- if vY_adjusted > 767.0 then
- --vY_adjusted = 767.0
- end if
-
- end
-